package com.ins.common.utils;

import com.ins.model.entity.AppUser;

/**
 * 用户
 *
 * @author ins
 * @since 2023-3-10
 */
public class SecureUser {

    private static final ThreadLocal<AppUser> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 获取用户信息
     */
    public static AppUser getUser() {
        return THREAD_LOCAL.get();
    }

    /**
     * 获取用户ID
     */
    public static Long getUserId() {
        //return getUser().getId();
        //todo 暂时设置为1
        return 1L;
    }

    /**
     * 获取用户名
     *
     * @return {@link String}
     */
    public static String getUserName() {
        //return getUser().getUserName();
        return "刘备";
    }


    /**
     * 删除
     */
    public static void remove() {
        THREAD_LOCAL.remove();
    }


    public static void set(AppUser user) {
        THREAD_LOCAL.set(user);
    }
}